﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using ChineseSchool.Models.Hethong;

namespace ChineseSchool.BLL
{
    public class B_NewsType
    {
        private PetaPoco.Database db;
        public B_NewsType()
        {
            db = new PetaPoco.Database("ConnectionString");
        }

        public DataTable GetAll()
        {
            DataTable dt = new DataTable();
            dt = db.ExecuteReader("EXEC NewsType_Get_List");
            return dt;
        }
        
        public List<M_NewsType> GetAlls()
        {
            var NewsType = db.Fetch<M_NewsType>(@";EXEC NewsType_Get_List");
            return NewsType;
        }

        public M_NewsType GetByPK(int NewsTypeID)
        {
            var loadNewsType = db.SingleOrDefault<M_NewsType>("SELECT * FROM NewsType m WHERE m.NewsTypeID = " + NewsTypeID + ";");
            db.CloseSharedConnection();
            return loadNewsType;
        }        
    }
}